﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Http;
using System.Net.Http.Headers;
using XclusiveClient.Classes;

namespace XclusiveClient
{
    public partial class EditEmployee : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://localhost:" + Session["portNumber"] + "/");
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            Session["employeeID"] = Request.QueryString["employeeID"];

            HttpResponseMessage response = client.PostAsJsonAsync("api/Employee/?employeeID=", Session["employeeID"]).Result;
            if (response.IsSuccessStatusCode)
            {
                var emp = response.Content.ReadAsAsync<Employee>().Result;
                lblemployeeID.Text = emp.employeeID.ToString();
                tbxname.Text = emp.name.ToString();
                lblcompany_name.Text = emp.company_name.ToString();
                lblaccount_type.Text = emp.account_type.ToString();
            }
            else
            {
                lblStatus.Text = "Could not register for an account. Error code: " + response.StatusCode + ", Reason: " + response.ReasonPhrase.ToString() + "<br/>";
            }
        }
    }
}